<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>

<script>
import FileUpload from "@/components/FileUpload/index";
export default {
  mixins: [
          Vue.prototype.$vFN.Mixins.Base,
          Vue.prototype.$vFN.Utils,
          ],
  components: { FileUpload },
  data() {
    return {
      load: true,

      form: {

        isChecked:  "",             // 是否复核
        merchantKey: "",            //  商户秘钥
        merchantNo: "",             //  商户编号

        paidUse: "",                // 代付用途
        productCode: "",            // 产品类型

        tradeMerchantNo: "",        // 报备商户号 
      },
      
      show: true,

      paidUseList: [
        {
          name: "工资资金",
          value: "201",
        },
        {
          name: "活动经费",
          value: "202",
        },
        {
          name: "养老金",
          value: "203",
        },
        {
          name: "货款",
          value: "204",
        },
         {
          name: "劳务费",
          value: "205",
        },
         {
          name: "保险理财",
          value: "206",
        },
           {
          name: "资金下发",
          value: "207",
        },
             {
          name: "营业退款",
          value: "208",
        },
          {
          name: "其他",
          value: "209",
        },
         {
          name: "退回款项",
          value: "210",
        },
         {
          name: "消费款项",
          value: "211",
        },
      ],

      productCodeList: [
        {
          name: "普通代付",
          value: "BANK_PAY_ORDINARY_ORDER",
        },
         {
          name: "朝夕付",
          value: "BANK_PAY_DAILY_ORDER",
        },
         {
          name: "任意付",
          value: "BANK_PAY_MAT_ENDOWMENT_ORDER",
        },
         {
          name: "组合付",
          value: "BANK_PAY_COMPOSE_ORDER",
        },
      ],

      apiUrl: {
        detail: "mall-site-portal/huiju-payment-config/getItem",
        save: "mall-site-portal/huiju-payment-config/saveOrUpdate",
      },
    };
  },
  mounted() {},
  methods: {
    init() {
      this.getData();
    },

    // 保存
    async submit() {

    if (!await this.validate()) {
        return
      }

      this.load = true;
      // console.log("保存参数",this.form)

      let _data = await this.$vFN.Http.post({
        url: this.apiUrl.save,
        data: this.form,
      },window);

      if (_data._ok) {
        this.init();
        this.$vFN.Tools.messageSuccess("保存修改成功");
      }

       this.load = false;
    },

    // 验证 
    validate() {
      return new Promise((resolve, reject) => {
              this.$refs["editForm"].validate((valid) => {
                  valid ? resolve(true) : resolve(false)
            });
        });
    },


    // 获取内容信息
    async getData() {
      this.load = true;

      let _data = await this.$vFN.Http.post({
        url: this.apiUrl.detail,
      },window);
      if (_data._ok) {

        for(let i in this.form){
            if(!this.$vFN.Utils.isEmpty(_data.data[i])){
                this.form[i] = _data.data[i];
            }
        }

          // 如果添加过密钥，需要显示加密
        if(!this.$vFN.Utils.isEmpty(_data.data.merchantKeyDesensitized)){
              this.form.merchantKey = _data.data.merchantKeyDesensitized;
        }

      }

     this.load = false;
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>
